package main

import (
	"fmt"
	"time"
)

func sayHello() {
	for i := 0; i < 10; i++ {
		fmt.Println("Hello")
		time.Sleep(1 * time.Second)
	}
}

func test() {
	// 这里可以使用defer + recover来捕获协程中的异常
	defer func(){
		if err := recover(); err!= nil {
			fmt.Println("捕获到异常：", err)
		}
	}()
	var myMap map[int]string
	myMap[0] = "golang"
}

func main() {
	
	go sayHello()
	go test()

	time.Sleep(5 * time.Second)
}